/*
 * MineralActivity.cpp
 *
 *  Created on: 20 Aug 2011
 *      Author: Allan
 */

#include "MineralActivity.h"

MineralActivity::MineralActivity() 
{}

MineralActivity::MineralActivity(const vector<string>& species) :
AuxiliaryActivity(species, IdealMineralModel())
{}

MineralActivity::~MineralActivity()
{}

const VectorXd MineralActivity::Activities(double T, double P, const VectorXd& n) const
{
	VectorXd a(n.rows());
	
	// The reciprocal of the total number of moles of the gaseous species
	const double ntotalRec = 1.0/n.sum();
	
	// Calculate the activity of each mineral species as the product of its molar fraction with its activity coefficient
	for(int i = 0; i < a.rows(); ++i) 
		a[i] = (ntotalRec * n[i]) * activitycoeffs[i](T, P, n);
	
	return a;
}

const ActivityCoefficient IdealMineralModel()
{
	// The ideal model for the gaseous activity coefficient (gamma = P)
	auto ideal = [](double T, double P, const VectorXd& n) { return 1.0; };	
	return ideal;
}
